<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
    <title>session管理</title>
    <%@ include file="../../include/head.jsp"%>
</head>
<body>
<div class="admin-content">
    <div class="am-g">
        <div class="am-u-sm-12">
            <div class="am-panel-group" id="accordion" style="display: none;">
                <div class="am-panel am-panel-default">
                    <div class="am-panel-hd">
                        <h4 class="am-panel-title" data-am-collapse="{parent: '#accordion', target: '#tab1'}">
                            查询条件
                        </h4>
                    </div>
                    <div id="tab1" class="am-panel-collapse am-collapse am-in">
                        <div class="am-panel-bd">
                            <form id="searchForm" action="${ctx}/session" method="post">
                                <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
                                <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
                                <div class="am-form-group">
                                    <button type="submit" class="am-btn am-btn-success" onclick="initSearchForm()"><i class="am-icon-search"></i> 查询</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <div class="am-panel am-panel-default">
                <div class="am-panel-hd">
                    <h4 class="am-panel-title">
                        查询列表
                    </h4>
                </div>
                <div class="am-panel-collapse am-collapse am-in">
                    <div class="am-panel-bd">
                        <div class="am-g">
                            <div class="am-u-sm-12">
                                <table class="am-table am-table-striped am-table-hover table-main">
                                    <thead>
                                    <tr>
                                        <th>会话</th>
                                        <th>用户</th>
                                        <th>IP地址</th>
                                        <th>过期时间(毫秒)</th>
                                        <th>启动时间</th>
                                        <th>最后访问时间</th>
                                        <th>已强制退出</th>
                                        <shiro:hasPermission name="sys:session:forceLogout"><th>操作</th></shiro:hasPermission>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <c:forEach items="${page.list}" var="session" varStatus="status">
                                        <tr>
                                            <td>${session.id}</td>
                                            <td>${fnc:principal(session)}</td>
                                            <td>${session.host}</td>
                                            <td>${session.timeout}</td>
                                            <td><fmt:formatDate value="${session.startTimestamp}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
                                            <td><fmt:formatDate value="${session.lastAccessTime}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
                                            <td>${fnc:isForceLogout(session) ? '<span class="am-badge am-badge-danger am-radius">是</span>':'<span class="am-badge am-badge-success am-radius">否</span>'}</td>
                                            <shiro:hasPermission name="sys:session:forceLogout"><td>
                                                <c:if test="${not fnc:isForceLogout(session)}">
                                                    <div class="am-btn-toolbar">
                                                        <div class="am-btn-group am-btn-group-xs">
                                                            <button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" onclick="iuConfirm('确认要强制注销吗？', '${ctx}/session/forceLogout?sessionId=${session.id}&pageNo=${page.pageNo}&pageSize=${page.pageSize}')"><span class="am-icon-sign-out"></span> 注销</button>
                                                        </div>
                                                    </div>
                                                </c:if>
                                            </td></shiro:hasPermission>
                                        </tr>
                                    </c:forEach>
                                    </tbody>
                                </table>
                            </div>
                            <div class="am-u-sm-12">
                                <%@ include file="../../utils/pagination.jsp" %>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<%@ include file="../../include/bottom.jsp"%>
<script type="text/javascript">
    $(document).ready(function () {
        var msg = '${msg}';
        if(msg!=''){
            iuMsg(msg);
        }
    });
</script>
</body>
</html>
